﻿using System;
using WorldMapBase.Display;
using WorldMapBase.Tile.Pool;

namespace WorldMapBase.Tile
{
    public class WorldObjectDisplayElementFactory : DisplayElementFactory
    {
        private Action<WorldObject> m_RecoverItemAction;

        public WorldObjectDisplayElementFactory()
        {
            m_RecoverItemAction = (worldObject) =>
            {
                WorldPoolManager.RecoverItem(worldObject);
            };
        }

        protected override IDisplayElement OnCreateDisplayElement(int lodIndex,int mapLayer,int resID)
        {
            return WorldPoolManager.GetWorldObject(lodIndex,mapLayer,resID);
        }

        protected override void OnDestroyDisplayElement(IDisplayElement element)
        {
            WorldPoolManager.RecoverItem(element as WorldObject);
        }
    }
}